<?php

namespace app\index\command;

use app\index\controller\Compute as Schedule;
use app\index\controller\Crontask;
use think\Config;
use think\console\Input;
use think\console\Output;
use think\Log;

/**
 * compute 任务由系统 cli 程序调用，统计用户最新留存
 */
class Compute extends Crontask
{


    //描述配置
    protected function configure()
    {
        $this->setName('compute')

            ->setDescription('Compute User Retention');
    }
    /**
     * 计算留存
     * @return   void
     */
    protected function execute(Input $input, Output $output)
    {

        try {

            //日志目录
            //
            $this->logInit('compute');

            $schedule = new Schedule();
            $calcDate = $schedule->manualUpdateRetention();

        } catch (\Exception $e) {

            //记录留存统计异常
            Log::record($e->getMessage(), 'log');
            throw new \think\Exception('异常消息:' . $e->getMessage());
        }
    }
}
